<template>
  <div class="admin-container">
    <AdminHeader></AdminHeader>
    <main class="admin-box">
      <Drawer class="admin-nav"></Drawer>
      <!-- <Main class="admin-main"></Main> -->
      <router-view class="admin-main"></router-view>
    </main>
  </div>
</template>

<script>
import AdminHeader from '@/components/AdminHeader'
import Drawer from '@/components/Drawer'

export default {
  watch: {
    $route (to, from) {
      if (to.path !== from.path) {
        console.log('路由变化，更新中...')
      }
    }
  },
  beforeRouteEnter (to, from, next) {
    next((vm) => {
      if (!vm.$store.state.isAdmin) {
        vm.$router.push('/adminLogin')
      }
      if (from.path === '/adminLogin' && to.path === '/admin/sysInfo') {
        vm.$nextTick(_ => {
          vm.$router.go(0)
        })
      }
    })
  },
  components: {
    AdminHeader,
    Drawer
  }
}
</script>

<style lang="less" scoped>
.admin-container{
  display: flex;
  flex-direction: column;
}
.admin-box{
  display: flex;
  flex-direction: row;
  justify-content: center;
  margin-top: 25px;
}
</style>
